#-*- coding:utf-8 -*-
"""
添加全局表达式
作用：
    将mz_paomadeng下的所有子物体添加进表达式
注意：
    需要选择Houdini Asset
"""
import maya.cmds as cmds


def set_exp():
    childs = cmds.ls(sl=1, dag=1, l=1, type=['mesh'])
    if childs:
        expression_name = childs[1].split('|')[1]
        count = 0
        scprits = ''
        for shape in childs:
            cmds.setAttr('{}.aiTranslator'.format(shape), 'mesh_light', type='string')
            # ss = '''int $show_{0} = `getAttr {1}.show`;setAttr "{1}.lightVisible" $show_{0};'''.format(count, shape)
            # ss = '''int $show_{0} = `getAttr {1}.show`;string $ty[] = {"polymesh", "mesh_light"};setAttr "{1}.aiTranslator"  -type "string" $ty[$show_{0}];'''.format(count, shape)
            ss = '''int $show_%s = `getAttr %s.show`;string $ty[] = {"polymesh", "mesh_light"};setAttr "%s.lightVisible" $show_%s;setAttr "%s.aiTranslator"  -type "string" $ty[$show_%s];'''%(count,shape,shape,count,shape,count)
            scprits += ss
            count += 1
        # print(scprits)
        cmds.expression(name='exp_'+expression_name, s=scprits)




set_exp()